package cn.tedu.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

public class JDBCTest04 {
    public static void main(String[] args) {
        //gerConnection的重载方法
        /*try {
            Class.forName("com.mysql.cj.jdbc.Driver");
            String url = "jdbc:mysql://localhost:3306/jdbc?user=root&password=root&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true";
            Connection conn = DriverManager.getConnection(url);
            System.out.println(conn);
        } catch (ClassNotFoundException | SQLException e) {
            e.printStackTrace();
        }*/

        //getConnection(url)
        try {
            //getConnection(url,info)
            Class.forName("com.mysql.cj.jdbc.Driver");
            //url
            String url = "jdbc:mysql://localhost:3306/jdbc";
            //info
            Properties info = new Properties();
            info.setProperty("user","root");
            info.setProperty("password","root");
            info.setProperty("useUnicode","true");
            info.setProperty("characterEncoding","utf8");
            info.setProperty("useSSL","false");
            info.setProperty("allowPublicKeyRetrieval","true");


            Connection conn = DriverManager.getConnection(url,info);

            System.out.println("====>"+conn);

        } catch (ClassNotFoundException | SQLException e) {
            e.printStackTrace();
        }

    }
}
